package centralRepository;

public class ServerObjectImpl extends ServerObjectPOA {
	
	public enum Status {RUNNING, DOWN, WAITING}; 
	
	private int portNum, edPortNum, lePortNum;
	private String station;
	private boolean leader;
	private Status status;
	private String name;
	private int id;
	private String hostname;
	
	public ServerObjectImpl(int portNum, int edPortNum, int lePortNum, String station, boolean leader, Status status, String name, int id, String hostname) {
		this.portNum = portNum;
		this.edPortNum = edPortNum;
		this.lePortNum = lePortNum;
		this.station = station;
		this.leader = leader;
		this.status = status;
		this.setName(name);
		this.id=id;
		this.setHostname(hostname);
	}
	
	public ServerObjectImpl(ServerObjectImpl serverObject) {
		this.portNum = Integer.parseInt(serverObject.getPortNum());
		this.edPortNum = Integer.parseInt(serverObject.getEdPortNum());
		this.lePortNum = Integer.parseInt(serverObject.getLePortNum());
		this.station = serverObject.getStation();
		this.leader = serverObject.isLeader();
		this.status = Status.valueOf(serverObject.getStatus());
		this.name = serverObject.getName();
		this.id=Integer.parseInt(serverObject.getId());
		this.hostname=serverObject.getHostname();
	}
	
	public ServerObjectImpl(ServerObject serverObject) {
		this.portNum = Integer.parseInt(serverObject.getPortNum());
		this.edPortNum = Integer.parseInt(serverObject.getEdPortNum());
		this.lePortNum = Integer.parseInt(serverObject.getLePortNum());
		this.station = serverObject.getStation();
		this.leader = serverObject.isLeader();
		this.status = Status.valueOf(serverObject.getStatus());
		this.name = serverObject.getName();
		this.id=Integer.parseInt(serverObject.getId());
		this.hostname=serverObject.getHostname();
	}
	public String getPortNum() {
		return ""+portNum;
	}
	public void setPortNum(int portNum) {
		this.portNum = portNum;
	}
	public String getStation() {
		return station;
	}
	public void setStation(String address) {
		this.station = address;
	}
	public boolean isLeader() {
		return leader;
	}
	public void setLeader(boolean leader) {
		this.leader = leader;
	}
	public String getStatus() {
		return status.toString();
	}
	public void setStatus(Status status) {
		this.status = status;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getId() {
		return ""+id;
	}
	public void setId(int id) {
		this.id = id;
	}
	@Override
	public void setStatus(String status) {
		this.status=Status.valueOf(status);	
	}
	public String getEdPortNum() {
		return ""+edPortNum;
	}
	public void setEdPortNum(int edPortNum) {
		this.edPortNum = edPortNum;
	}
	public String getLePortNum() {
		return String.valueOf(lePortNum);
	}
	public void setLePortNum(int lePortNum) {
		this.lePortNum = lePortNum;
	}
	public String getHostname() {
		return hostname;
	}
	public void setHostname(String hostname) {
		this.hostname = hostname;
	}
	@Override
	public String toString() {
		return "ServerObjectImpl [portNum=" + portNum + ", edPortNum="
				+ edPortNum + ", lePortNum=" + lePortNum + ", station="
				+ station + ", leader=" + leader + ", status=" + status
				+ ", name=" + name + ", id=" + id + ", hostname=" + hostname
				+ "]";
	}

}
